<?php

	//Header, DB-Connection und Navigation einbinden
	include "inc_header.php";
	include "inc_openDBConn.php";
	include "inc_navigation.php";
	include "login.php";
	
	//--------------------------------------------------------------------------
	//Beginn Content
	echo '<div id="content">';
	
	//Query "Ausgabe Eintraege"
	$result = mysqli_query($db,"SELECT * FROM posts 
							INNER JOIN authors 
							ON posts.authorID = authors.authorID 
							ORDER BY date DESC");
	
	//Daten ausgeben
	while($row = mysqli_fetch_array($result))
	{
		echo "<div class='post'>
				<div class='post_title'>
					<a href='detail.php?post=" . $row['id'] . "'>" . htmlspecialchars($row['title']) . "</a>
						<div class='post_author'>
						by " . htmlspecialchars($row['name']). "
						</div><br />
				</div>
				<div class='post_date'>
					" . $row['date'] . "<br />
				</div>
				<div class='post_text'>
					" . substr(htmlspecialchars($row['text']),0,400) . "<a href='detail.php?post=" . $row['id'] . "'>[weiterlesen]</a>
				</div>
			</div>";
	}
	
	//DB-Verbindung schliessen
	include "inc_closeDBConn.php";
	
	//Footer einbinden
	include "inc_footer.php";
	
	//Ende Content
	//--------------------------------------------------------------------------
	
?>